﻿<UserControl x:Class="BingSpatialDataServiceExcelAddin.Views.DataSourceJobListBox"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:converters="clr-namespace:BingSpatialDataServiceExcelAddin.Views.Converters"
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">
    
    <UserControl.Resources>
        <ResourceDictionary>
            <converters:VisibilityConverter x:Key="visibilityConverter"/>
            <converters:StatusConverter x:Key="statusConverter"/>
        </ResourceDictionary>
    </UserControl.Resources>
    
    <Grid>
        <ListBox ItemsSource="{Binding}">
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <Grid Margin="5">
                        <Grid.RowDefinitions>
                            <RowDefinition/>
                            <RowDefinition/>
                            <RowDefinition/>
                            <RowDefinition/>
                        </Grid.RowDefinitions>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="250"/>
                            <ColumnDefinition />
                        </Grid.ColumnDefinitions>

                        <StackPanel Orientation="Horizontal">
                            <TextBlock Text="Job ID: "/>
                            <TextBlock Text="{Binding Id}" FontWeight="Bold"/>
                        </StackPanel>

                        <StackPanel Orientation="Horizontal" Grid.Row="1">
                            <TextBlock Text="Created Date: "/>
                            <TextBlock Text="{Binding CreatedDate}" FontWeight="Bold"/>
                        </StackPanel>

                        <StackPanel Orientation="Horizontal" Grid.Row="2">
                            <TextBlock Text="Job Description: "/>
                            <TextBlock Text="{Binding Description}" FontWeight="Bold"/>
                        </StackPanel>

                        <StackPanel Orientation="Horizontal" Grid.Row="3">
                            <TextBlock Text="Status: "/>
                            <TextBlock Text="{Binding Status}" FontWeight="Bold" Foreground="{Binding Status, Converter={StaticResource statusConverter}}"/>
                        </StackPanel>

                        <Button Content="Details" Grid.RowSpan="4" Grid.Row="0" Grid.Column="1" VerticalAlignment="Top" Margin="0,0,10,0" Width="60" Height="25" Click="DetailsBtn_Click" Tag="{Binding}"/>
                    </Grid>
                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox>
    </Grid>
</UserControl>
